/**
 * ...
 * @author Franco Ponticelli
 */

package uform.property;

class LimitedStringPropertyDecorator extends PropertyDecorator<String>
{
	public var maxLength(default, setMaxLength) : Null<Int>;
	
	function setMaxLength(value : Null<Int>)
	{
		maxLength = value;
		set(get());
		return maxLength;
	}
	
	override function set(value : String) : IProperty<String>
	{
		if (maxLength != null && value != null && value.length > maxLength)
		{
			value = value.substr(0, maxLength);
		}
		decorated.set(value);
		return this;
	}
}